#!/usr/bin/env python

import sys    
import os
from Tkinter import *                        
from tkFileDialog   import askopenfilename
from tkMessageBox import *


try:
  # attempt to use the installed python package
  from bbvisa2ofx import bbvisa2ofx
except:
  # attempt to run the package from the source directory
  sys.path.insert (0,'src')
  from bbvisa2ofx import bbvisa2ofx
  
def main():
	pathTxt = askopenfilename()
	if(not os.path.isfile(pathTxt)):
	    print "File not found: %s" % pathTxt
	else:
		fileTxt = open(pathTxt,'r')
		fileOfx = open(pathTxt + ".ofx",'w')
		bbvisa2ofx.convert(pathTxt,fileOfx)
		

	
	

if __name__ == '__main__':
  main()